/*
 * FireBall.h
 *
 *  Created on: 02/09/2010
 *      Author: alex
 */

#ifndef FIREBALL_H_
#define FIREBALL_H_

#include <cmath>
#include "GameObject.h"


class FireBall: public GameObject {

public:

	FireBall() : GameObject("img/sprites/weapons/fire.png"), isReady(true) {}

	FireBall& enable(double angle, GameObject* owner) {
		this->owner = owner;
		this->angle = angle;
		isReady = false;
		life = 10;
		return *this;
	}

	FireBall& disable() {
		isReady = true;
		return *this;
	}

	bool ready() const {
		return isReady;
	}

	FireBall& update(int dt) {
		if (isReady) return *this;
		if (x < -1000 || x > 1000 || y < -600 || y > 600) {
			hit(10);
			disable();
		}
		x += cos(angle*3.1415926/180) * 0.2 * dt;
		y -= sin(angle*3.1415926/180) * 0.2 * dt;
		return *this;
	}

	GameObject* owner;

protected:

	double angle;

	bool isReady;

};

#endif /* FIREBALL_H_ */
